<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

	<head>

		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>选择服务位置</title>

		<link rel="stylesheet" href="../css/mui.min.css" />
		<link rel="stylesheet" href="../css/main.css" />
		<link rel="stylesheet" href="../css/mui.picker.css" />
		<link rel="stylesheet" href="../css/mui.poppicker.css" />
		<link rel="stylesheet" href="../css/feedback.css" />
		<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=x8wP7ck7pQ4P8UAol2pen8B5"></script>

		<style>
			.mui-content {
				margin-top: 0.08rem;
				font-size: 0.2916rem;
			}

			#zhaoxiang {
				height: 2rem;
			}

			#zhaoxiang.mui-table-view-cell {
				padding-top: 0.3rem;
				height: 130px;
			}

			#zhaoxiang a span:after {
				top: 40%;
			}

			#head_image {
				width: 90px;
				height: 90px;
				border-radius: 50px;
				margin-top: 10px;
			}

			.head {
				margin-top: -0.6rem;
				margin-right: 15px;
			}

			.mui-content>.mui-table-view:first-child {
				margin-bottom: 0.08rem;
			}

			#libiao li {
				height: 1.0rem;
				padding-top: 0.25rem;
			}

			#libiao li span {
				margin-right: 20px;
				font-size: 14px;
			}

			.qianming {
				width: 50%;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
				text-align: right;
			}

			.mui-table-view-cell:after {
				left: 0;
			}

			.mui-navigate-right:after {
				font-size: 25px;
				right: 5px;
			}

			.mui-table-view-cell a {
				color: #424242;
			}

			.mui-table-view-cell span {
				color: #999999;
			}

			#forward {
				font-size: 0.3124rem;
				font-weight: 400;
			}

			#male {
				color: #00c0ff;
				height: 1.1rem;
			}

			#female {
				color: #ff0072;
				height: 1.1rem;
			}

			#male div,
			#female div {
				background: url(../../../image/tubiao2.png) no-repeat;
			}

			.redword {
				color: #FF3300 !important;
			}

			.shengfen_upload {
				max-width: 100%;
				background: #FFFFFF;
				height: 200px;
				padding-top: 70px;
			}

			.mui-content-padded a {
				margin: 3px;
				width: 50px;
				height: 50px;
				display: block;
				text-align: center;
				background-color: #fff;
				border: 1px solid #ddd;
				border-radius: 25px;
				background-clip: padding-box;
				margin: 0 auto;
			}

			.mui-content-padded a .mui-icon {
				margin-top: 12px;
				color: #000000;
				margin-top: -7px;
				margin-left: -6px;
			}

			.mui-icon {
				font-size: 60px;
			}

			.upload_word {
				margin: 10px auto;
				display: block;
				text-align: center;
			}

			.shenfen_card,
			.sign_name {
				width: 70% !important;
				height: 20px !important;
				font-size: 14px;
			}

			.error_shenfen_card {
				border: 1px dotted rgba(0, 0, 0, 0) !important;
			}

			.right_shenfen_card {
				border: 1px solid rgba(0, 0, 0, 0) !important;
			}

			input[type="number"] {
				border: 1px solid rgba(0, 0, 0, 0) !important;
			}

			.mui-table-view .mui-table-view-cell {
				/*margin-top:1.4rem;*/
			}

			.mui-table-view .one {
				margin-top: 0px;
			}

			.mui-table-view .mui-table-view-cell .labelL .artle b {
				font-style: normal !important;
				color: #FF6600
			}

			.mui-content .mui-table-view li {}

			#libiao li {
				height: 1.2rem;
				padding-top: 0.25rem;
			}

			.mui-content {
				margin-top: 0.08rem;
				font-size: 0.2916rem;
				height: 0;
			}

			#container {
				width: 600px;
				height: 400px
			}

			.label {
				margin-left: 20px;
				font-weight: bold;
				font-size: 14px
			}

			.mapchangchun {
				position: fixed;
				top: 60px;
				left: 20px;
				font-size: 16px;
				line-height: 34px;
				position: absolute;
				z-index: 1;
				width: 90%;
				text-align: center;
				color: #999;
				border: 0;
				border-radius: 6px;
				background: 0 0;
			}

			.mui-content {
				margin-top: 70px;
			}
			/*.mapchangchun .tip img {
		   	width: 0.5rem;
		   	position: ;
		   }*/
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">选择服务位置</h1>
		</header>

		<div class="mui-input-row mapchangchun">
			<div id="l-map"></div>
			<input type="search" class="searchinput" id="ADDRESS_NAME_BEGIN" name="ADDRESS_NAME_BEGIN" placeholder="请输入起点" title="起点" />
			<!--<div id="searchResultPanel_begin"></div>-->
			<!--<div class="tip"><img src="../images/sousuo.png" alt="" /></div>-->
		</div>

		<script src="../js/mui.min.js"></script>
		<script src="../js/xiangyingshi.js"></script>
		<script type="text/javascript" src="../js/constants.js"></script>
		<script type="text/javascript" src="../js/sharemethods.js"></script>
		<script type="text/javascript" src="../js/jquery-3.1.1.min.js"></script>
		<script type="text/javascript" src="../js/mui.picker.js"></script>
		<script type="text/javascript" src="../js/mui.poppicker.js"></script>
		<script type="text/javascript" src="../js/exif.js"></script>





		<script type="text/javascript">
			function G(id) {
				return document.getElementById(id);
			}

			var map = new BMap.Map("l-map");
			map.centerAndZoom("长春", 12); // 初始化地图,设置城市和地图级别。

			var ac = new BMap.Autocomplete( //建立一个自动完成的对象
				{
					"input": "ADDRESS_NAME_BEGIN",
					"location": map
				});

			ac.addEventListener("onhighlight", function(e) { //鼠标放在下拉列表上的事件
				var str = "";
				var _value = e.fromitem.value;
				var value = "";
				if(e.fromitem.index > -1) {
					value = _value.province + _value.city + _value.district + _value.street + _value.business;
				}
				str = "FromItem<br />index = " + e.fromitem.index + "<br />value = " + value;

				value = "";
				if(e.toitem.index > -1) {
					_value = e.toitem.value;
					value = _value.province + _value.city + _value.district + _value.street + _value.business;
				}
				str += "<br />ToItem<br />index = " + e.toitem.index + "<br />value = " + value;
				//G("searchResultPanel_begin").innerHTML = str;
			});

			var myvaluetwo;
			ac.addEventListener("onconfirm", function(e) { //鼠标点击下拉列表后的事件
				var _value = e.item.value;
				myvaluetwo = _value.province + _value.city + _value.district + _value.street + _value.business;
				console.log(myvaluetwo);
				document.getElementById("ADDRESS_NAME_BEGIN").value = myvaluetwo;
				//G("searchResultPanel_begin").innerHTML = "onconfirm<br />index = " + e.item.index + "<br />myValue = " + myValue;
				localStorage.myvaluetwo = myvaluetwo;
				//setCookie("myvalue", myValue);
//				location.href = "./service_position.html";
				setPlace(myvaluetwo)
			});


				function setPlace() {
				map.clearOverlays(); //清除地图上所有覆盖物
				//经度

				var local = new BMap.LocalSearch(map, { //智能搜索
					onSearchComplete: function(){
						var pp = local.getResults().getPoi(0).point; //获取第一个智能搜索的结果
					    //document.getElementById("ADDRESS_LNG_BEGIN").value = pp.lng; //获取经度
					    //document.getElementById("ADDRESS_LAT_BEGIN").value = pp.lat; //获取纬度
						//console.log(pp.lng)
						//console.log(pp.lat)

						document.getElementById("LNG").value = pp.lng;
						document.getElementById("LAT").value = pp.lat;
//						localStorage.myvalue = myValue;
						var longitude= pp.lng;
						var latitude= pp.lat;
						localStorage.longitude = longitude;
						localStorage.latitude = latitude;

					}
				});
				local.search(myValuetwo);
			});
			function setPlace(myValuetwo) {
					map.clearOverlays(); //清除地图上所有覆盖物
					//经度

					var local = new BMap.LocalSearch(map, { //智能搜索
						onSearchComplete: function() {
							var pp = local.getResults().getPoi(0).point; //获取第一个智能搜索的结果
							//document.getElementById("ADDRESS_LNG_BEGIN").value = pp.lng; //获取经度
							//document.getElementById("ADDRESS_LAT_BEGIN").value = pp.lat; //获取纬度
							//console.log(pp.lng)
							//console.log(pp.lat)

							document.getElementById("LNG").value = pp.lng;
							document.getElementById("LAT").value = pp.lat;
							//						localStorage.myvalue = myValue;
							var longitude = pp.lng;
							var latitude = pp.lat;

							localStorage.longitude = longitude;
							localStorage.latitude = latitude;

							var id = localStorage.getItem("USERID");
							var accessToken = localStorage.getItem("ACCESSTOKEN");

							var url = serverAddress + "/doctor/workaddressandgps/" + id;
							console.log(url);
							mui.ajax(url, {
								data: {
									id: id,
									access_token: accessToken,
									workgps: {
										"lng": longitude,
										"lat":latitude
									},
									workaddress: myValuetwo
								},
								dataType: 'json', //服务器返回json格式数据
								type: 'put', //HTTP请求类型
								timeout: 180000, //超时时间设置为30秒；

								success: function(data) {
									//服务器返回响应，根据响应结果，分析是否登录成功；
									console.log(JSON.stringify(data));
									if(data.result == "success") {

										mui.back();
										var sevice_item_xiangqing = plus.webview.getWebviewById('service_position');
										mui.fire(sevice_item_xiangqing, "sevice_item_xiang", {
											WORK_VALUE: workaddress
										});

									}
								},
								error: function(xhr, type, errorThrown) {
									console.log(xhr.status);
									console.log(xhr.readyState);
									console.log(type);
									console.log(errorThrown);
									//异常处理；
									mui.toast('获取医院网络超时，请稍后再试！');
									plus.nativeUI.closeWaiting();
								}
							});
						}
					});
					local.search(myValuetwo);
				}









		</script>
	</body>

</html>